<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <ui:composition template="/template.xhtml">
        
        <ui:define name="title">
            <h:outputText value="#{bundle.ListSituacaoTitle}"></h:outputText>
        </ui:define>
        
        <ui:define name="body">
                
                <h:panelGroup id="messagePanel" layout="block">
                    <p:growl />
                </h:panelGroup>
            
            <h:form id="formSituacaoList">
                
                <h:panelGroup>
                    
                    <p:dataTable id="tableSituacao" value="#{situacaoController.items}" var="item"
                                 emptyMessage="#{bundle.ListSituacaoEmpty}">
                        
                        <f:facet name="header">#{bundle.ListSituacaoTitle}</f:facet>
                        
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListSituacaoTitle_descricao}"/>
                            </f:facet>
                            <h:outputText value="#{item.descricao}"/>
                        </p:column>
                        
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListSituacaoTitle_condicao}"/>
                            </f:facet>
                            <h:outputText value="#{item.condicao}"/>
                        </p:column>
                        
                        <p:column>
                            <f:facet name="header">
                                <p:commandButton actionListener="#{situacaoController.prepareCreate}" 
                                                 value="#{bundle.ListSituacaoCreateLink}"
                                                 update=":formSituacaoCreate:pgSituacaoCreate" 
                                                 oncomplete="dialogSituacaoCreate.show()"/>
                            </f:facet>
                            <p:commandButton actionListener="#{situacaoController.prepareEdit}" 
                                             value="#{bundle.ListSituacaoEditLink}"
                                             update=":formSituacaoEdit:pgSituacaoEdit" 
                                             oncomplete="dialogSituacaoEdit.show()" />
                            <p:commandButton actionListener="#{situacaoController.destroy}" 
                                             value="#{bundle.ListSituacaoDestroyLink}" ajax="false"/>
                            
                        </p:column>
                        
                    </p:dataTable>
                </h:panelGroup>
                
            </h:form>

            <h:form id="formSituacaoCreate">

                <p:dialog header="#{bundle.CreateSituacaoTitle}" widgetVar="dialogSituacaoCreate" 
                          resizable="false" modal="true" showEffect="slide">
                    <p:panelGrid id="pgSituacaoCreate" columns="2">
                        <h:outputLabel value="#{bundle.CreateSituacaoLabel_descricao}" for="descricao" />
                        <p:inputText id="descricao" value="#{situacaoController.selected.descricao}" 
                                     title="#{bundle.CreateSituacaoTitle_descricao}" required="true"
                                     requiredMessage="#{bundle.CreateSituacaoRequiredMessage_descricao}"/>
                        <h:outputLabel value="#{bundle.CreateSituacaoLabel_condicao}" for="condicao" />
                        <p:inputText id="condicao" value="#{situacaoController.selected.condicao}" 
                                     title="#{bundle.CreateSituacaoTitle_condicao}" 
                                     required="true" requiredMessage="#{bundle.CreateSituacaoRequiredMessage_condicao}"/>
                        <p:commandButton actionListener="#{situacaoController.create}" 
                                         update=":formSituacaoList:tableSituacao" 
                                         value="#{bundle.CreateSituacaoSaveLink}" 
                                         oncomplete="#{situacaoController.prepareCreate}" ajax="false" />
                        <p:commandButton value="Limpar" type="reset" 
                                         update=":formSituacaoCreate:pgSituacaoCreate" ajax="false"/>
                    </p:panelGrid>
                </p:dialog>

            </h:form>

            <h:form id="formSituacaoEdit">

                <p:dialog header="#{bundle.EditSituacaoTitle}" widgetVar="dialogSituacaoEdit" resizable="false" modal="true" showEffect="slide">
                    <p:panelGrid id="pgSituacaoEdit" columns="2">
                        <h:outputLabel value="#{bundle.EditSituacaoLabel_descricao}" for="descricao" />
                        <p:inputText id="descricao" value="#{situacaoController.selected.descricao}" 
                                     title="#{bundle.EditSituacaoTitle_descricao}" required="true"
                                     requiredMessage="#{bundle.EditSituacaoRequiredMessage_descricao}"/>
                        <h:outputLabel value="#{bundle.EditSituacaoLabel_condicao}" for="condicao" />
                        <p:inputText id="condicao" value="#{situacaoController.selected.condicao}" 
                                     title="#{bundle.EditSituacaoTitle_condicao}" 
                                     required="true" requiredMessage="#{bundle.EditSituacaoRequiredMessage_condicao}"/>
                        <p:commandButton actionListener="#{situacaoController.update}" update=":formSituacaoList:tableSituacao" 
                                         value="#{bundle.EditSituacaoSaveLink}" oncomplete="dialogSituacaoEdit.hide()" ajax="false" />
                        <p:commandButton value="Cancelar" oncomplete="dialogSituacaoEdit.hide()" ajax="false"/>
                    </p:panelGrid>
                </p:dialog>

            </h:form>
            
        </ui:define>
    </ui:composition>

</html>
